package com.csun.cmny.provider.model.enums.device;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * @Auther: chisj chisj@foxmal.com
 * @Date: 2018-12-29 09:20
 * @Description:
 */
public enum DmcDeviceTypeEnum {

    /**
     * 随访仪
     */
    FOLLOW("tb_follow", "随访仪", 0),

    /**
     * 孝心手环
     */
    XX_WATCH("xx_watch", "孝心手环",1),

    /**
     * 睡眠卫士
     */
    BS_SLEEP("bs_sleep", "睡眠卫士", 2),

    /**
     * 电话机
     */
    ZN_PHONE("zn_phone", "电话机", 3),

    /**
     * 智能网关
     */
    CSUN_GATEWAY("csun_gateway", "智能网关", 4),

    /**
     * 紧急按钮
     */
    CSUN_BUTTON("csun_button", "紧急按钮", 5),

    /**
     * 人体感应
     */
    CSUN_BODY_SENSOR("csun_body_sensor", "人体感应", 6),

    /**
     * 门禁读卡器
     */
    RFID_READER("rfid_reader", "门禁读卡器", 7),

    /**
     * 门禁标签
     */
    RFID_LABEL("rfid_label", "门禁标签", 8),

    /**
     * 日创床垫
     */
    CSUN_SLEEP("csun_sleep", "日创床垫", 9),

    /**
     * 护工手表
     */
    HG_WATCH("hg_watch", "护工手表", 10),

    /**
     * 报警灯
     */
    ALARM_LIGHT("alarm_light", "报警灯", 11),

    /**
     * 智能摄像头
     */
    CSUN_CAMERA("csun_light", "智能摄像头", 12),

    /**
     * 床头屏
     */
    BEDSIDE_SCREEN("bedside_Screen", "床头屏", 13),

    /**
     * 门禁控制卡
     */
    CONTROLLER_CARD("controller_card", "门禁控制卡", 14),

    /**
     * 温湿度传感器
     */
    HUMIDISTAT("humidistat", "温度计", 15),

    /*日创新人感*/

    NEWBODY("newBody", "日创新人感", 16),

    /**
     * 日创门磁
     */
    CSUN_DOOR("csun_door", "日创门磁", 17),
    /**
     * 巡更棒
     */
    PATROL("patrol", "巡更棒", 19),
    /**
     * 巡更点
     */
    PATROL_POINT("patrol_point", "巡更点", 20),
    /**
     * 萤石摄像头
     */
    YS_CAMERA("ys_camera", "萤石摄像头", 21),
    /**
     * 红外探测器
     */
    INFRARED_DETECTOR("infraredDetector","红外探测器",22),
    /**
     * 紧急呼叫器
     */
    EMERGENCY_CALLER("emergencyCaller","紧急呼叫器",23),
    /**
     * 烟雾报警器
     */
    SMOKE_ALARM("smokeAlarm","烟雾报警器",24),
    /**
     * 煤气报警器
     */
    GAS_ALARM("gasAlarm","煤气报警器",25),
    /**
     * 溢水报警器
     */
    OVERFLOW_ALARM("overflowAlarm","溢水报警器",26),
    /**
     * 门磁感应器
     */
    DOOR_SENSOR("doorSensor","门磁感应器",27),
    /**
     * 魔盒网关
     */
    MOHE_GATEWAY("moheGaetway","魔盒网关",28),

    /**
     * 跌倒雷达
     */
    FALL_RADAR("fallRadar","跌倒雷达",29),
    ;

    /**
     * The Key.
     */
    String key;
    /**
     * The Value.
     */
    String value;

    /**
     * The Index
     */
    Integer index;

    DmcDeviceTypeEnum(String key, String value, Integer index) {
        this.key = key;
        this.value = value;
        this.index = index;
    }

    /**
     * Gets key.
     *
     * @return the key
     */
    public String getKey() {
        return key;
    }

    /**
     * Gets value.
     *
     * @return the value
     */
    public String getValue() {
        return value;
    }

    /**
     * Gets index.
     *
     * @return the value
     */
    public Integer getIndex() {
        return index;
    }

    /**
     * 获取key获取value
     *
     * @param key key
     *
     * @return value value
     */
    public static String getValue(String key) {
        for (DmcDeviceTypeEnum ele : DmcDeviceTypeEnum.values()) {
            if (key.equals(ele.getKey())) {
                return ele.getValue();
            }
        }
        return null;
    }

    public static String getKey(Integer index) {
        for (DmcDeviceTypeEnum ele : DmcDeviceTypeEnum.values()) {
            if (index.equals(ele.getIndex())) {
                return ele.getKey();
            }
        }
        return null;
    }

    /**
     * 根据key获取该对象
     *
     * @param key key
     *
     * @return this enum
     */
    public static DmcDeviceTypeEnum getEnum(String key) {
        for (DmcDeviceTypeEnum ele : DmcDeviceTypeEnum.values()) {
            if (key.equals(ele.getKey())) {
                return ele;
            }
        }
        return null;
    }

    /**
     * 获取List集合
     *
     * @return List list
     */
    public static List<DmcDeviceTypeEnum> getList() {
        return Arrays.asList(DmcDeviceTypeEnum.values());
    }

    public static List<Map<String, String>> getMaps() {
        List<Map<String, String>> list = Lists.newArrayList();
        for (DmcDeviceTypeEnum d : DmcDeviceTypeEnum.values()) {
            Map<String, String> map = Maps.newHashMap();
            map.put("key", d.getKey());
            map.put("value", d.getValue());
            list.add(map);
        }
        return list;
    }
}
